﻿@using MyData.Dto
@model MobileDto
@{
    ViewBag.Title = "MobileView";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/UI/js/jquery.idTabs.min.js"></script>
<script src="~/Content/UI/js/select-ui.min.js"></script>
<script type="text/javascript">
    $(function () {
        $(".select3").uedSelect({
            width: 120
        });
    })
</script>
<form id="form1">
    <div class="tools">
        <ul class="toolbar">
            <li class="click" onclick="fnSave()"><span><img src="../Content/UI/images/t02.png" /></span>保存</li>
        </ul>
    </div>

    <div class="formbody">
        <div id="usual1" class="usual">
            <div class="itab">
                <ul>
                    <li><a href="#tab1" class="selected">基本设置</a></li>
                    <li><a href="#tab2">开启限制</a></li>
                </ul>
            </div>
            <div id="tab1" class="tabson">
                <ul class="forminfo">
                    <li>
                        <label>设备名称:</label><input value="@Model.Name" type="text" class="dfinput" id="Name" name="Name" required />
                    </li>
                    <li>
                        <label>设备编码:</label><input value="@Model.ImeiNum" type="text" class="dfinput" id="ImeiNum" name="ImeiNum" required />
                    </li>
                    <li>
                        <label>设备IP:</label><input value="@Model.Ip" type="text" class="dfinput" id="Ip" />
                    </li>
                    <li>
                        <label>设备端口:</label><input value="@Model.Port" type="number" class="dfinput" id="Port" />
                    </li>
                    <li>
                        <label>相似阈值:</label><input value="@Model.Similar" type="number" class="dfinput" id="Similar" />
                    </li>
                    <li>
                        <label>白天开始:</label><div class="vocation">
                            <select class="select3" id="DayStart">
                                @{
                                    for (var i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i</option>
                                    }
                                }

                            </select>
                        </div>
                    </li>
                    <li>
                        <label>白天结束:</label><div class="vocation">
                            <select class="select3" id="DayEnd">
                                @{
                                    for (var i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i</option>
                                    }
                                }

                            </select>
                        </div>
                    </li>
                    <li>
                        <label>夜晚阈值:</label><input value="@Model.NightSimilar" type="number" class="dfinput" id="NightSimilar" />
                    </li>
                    <li>
                        <label>清晰阈值:</label><input value="@Model.Live1" type="number" class="dfinput" id="Live1" />
                    </li>
                    <li>
                        <label>活体阈值:</label><input value="@Model.Live2" type="number" class="dfinput" id="Live2" />
                    </li>
                    <li>
                        <label>持续时间:</label><input value="@Model.Duration" type="number" class="dfinput" id="Duration" />
                    </li>
                    <li>
                        <label>开门时间:</label><input value="@Model.DoorTime" type="number" class="dfinput" id="DoorTime" />
                    </li>

                    <li>
                        <label>设备状态:</label><cite><input name="State" type="radio" value="1" checked="checked" />开启&nbsp;&nbsp;&nbsp;&nbsp;<input name="State" type="radio" value="0" />关闭</cite>
                    </li>
                    <li>
                        <label>设备进出:</label><cite><input name="TurnOver" type="radio" value="0" checked="checked" />进门&nbsp;&nbsp;&nbsp;&nbsp;<input name="TurnOver" type="radio" value="1" />出门</cite>
                    </li>
                </ul>
                <input type="hidden" id="Id" value="@Model.Id.ToString()" />
            </div>

            <div id="tab2" class="tabson">
                <ul class="forminfo">
                    <li><label>限制状态</label><cite><input name="LimitState" type="radio" value="1" />开启&nbsp;&nbsp;&nbsp;&nbsp;<input name="LimitState" type="radio" value="0" checked="checked" />关闭</cite></li>
                    <li>
                        <label>周一</label>
                        <div class="vocation">
                            <select class="select3" id="MonStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i.ToString()">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="MonEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周二</label>
                        <div class="vocation">
                            <select class="select3" id="TueStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="TueEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周三</label>
                        <div class="vocation">
                            <select class="select3" id="WedStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="WedEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周四</label>
                        <div class="vocation">
                            <select class="select3" id="ThursStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="ThursEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周五</label>
                        <div class="vocation">
                            <select class="select3" id="FriStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="FriEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周六</label>
                        <div class="vocation">
                            <select class="select3" id="SatStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="SatEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                    <li>
                        <label>周日</label>
                        <div class="vocation">
                            <select class="select3" id="SunStart">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>

                        </div>
                        <div class="vocation">&nbsp;&nbsp;&nbsp;&nbsp;</div>
                        <div class="vocation">
                            <select class="select3" id="SunEnd">
                                @{
                                    for (int i = 0; i < 24; i++)
                                    {
                                        <option value="@i">@i.ToString("00")</option>
                                    }
                                }
                            </select>
                        </div>

                    </li>
                </ul>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $("#usual1 ul").idTabs();
    $("#DayStart").val('@Model.DayStart');
    $("#DayEnd").val('@Model.DayEnd');
    if ('@Model.Id' != '00000000-0000-0000-0000-000000000000') {
        $("input[name='State'][value=" + '@Model.State' + "]").attr("checked", true);
        $("input[name='TurnOver'][value=" + '@Model.TurnOver' + "]").attr("checked", true);
        $("input[name='LimitState'][value=" + '@Model.LimitState' + "]").attr("checked", true);
        $("#MonStart").val('@Model.MonStart.ToString()');
        $("#MonEnd").val('@Model.MonEnd');
        $("#TueStart").val('@Model.TueStart');
        $("#TueEnd").val('@Model.TueEnd');
        $("#WedStart").val('@Model.WedStart');
        $("#WedEnd").val('@Model.WedEnd');
        $("#ThursStart").val('@Model.ThursStart');
        $("#ThursEnd").val('@Model.ThursEnd');
        $("#FriStart").val('@Model.FriStart');
        $("#FriEnd").val('@Model.FriEnd');
        $("#SatStart").val('@Model.SatStart');
        $("#SatEnd").val('@Model.SatEnd');
        $("#SunStart").val('@Model.SunStart');
        $("#SunEnd").val('@Model.SunEnd');

    }

    function fnSave() {
        if ($('#form1').valid()) {
            $.post("../Mobile/SaveMobile", queryParams(), function (result) {
                if (result.state == 1) {
                    layer.msg('操作成功');
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index)
                    parent.$("#table").bootstrapTable('refresh');
                }
                else {
                    layer.msg(result.message);
                }
            })
        }
    }
    function queryParams() {
        return {
            Name: $("#Name").val(),
            ImeiNum: $("#ImeiNum").val(),
            Ip: $("#Ip").val(),
            Port: $("#Port").val(),
            Similar: $("#Similar").val(),
            Live1: $("#Live1").val(),
            Live2: $("#Live2").val(),
            DayStart: $("#DayStart").val(),
            DayEnd: $("#DayEnd").val(),
            NightSimilar: $("#NightSimilar").val(),
            Duration: $("#Duration").val(),
            DoorTime: $("#DoorTime").val(),
            State: $("input[name='State']:checked").val(),
            LimitState: $("input[name='LimitState']:checked").val(),
            TurnOver: $("input[name='TurnOver']:checked").val(),
            CameraIp: $("#CameraIp").val(),
            CameraPort: $("#CameraPort").val(),
            CameraName: $("#CameraName").val(),
            CameraPass: $("#CameraPass").val(),
            MonStart: $("#MonStart").val(),
            MonEnd: $("#MonEnd").val(),
            TueStart: $("#TueStart").val(),
            TueEnd: $("#TueEnd").val(),
            WedStart: $("#WedStart").val(),
            WedEnd: $("#WedEnd").val(),
            ThursStart: $("#ThursStart").val(),
            ThursEnd: $("#ThursEnd").val(),
            FriStart: $("#FriStart").val(),
            FriEnd: $("#FriEnd").val(),
            SatStart: $("#SatStart").val(),
            SatEnd: $("#SatEnd").val(),
            SunStart: $("#SunStart").val(),
            SunEnd: $("#SunEnd").val(),
            Id: $("#Id").val()
        };
    }
</script>

